import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ylm_ui_kit/ylm_ui_kit.dart';

class ChatVoiceRecordBar extends StatefulWidget {
  const ChatVoiceRecordBar({
    Key? key,
    required this.onLongPressStart,
    required this.onLongPressEnd,
    required this.onLongPressMoveUpdate,
  }) : super(key: key);

  final Function(LongPressStartDetails details) onLongPressStart;
  final Function(LongPressEndDetails details) onLongPressEnd;
  final Function(LongPressMoveUpdateDetails details) onLongPressMoveUpdate;

  @override
  State<ChatVoiceRecordBar> createState() => _ChatVoiceRecordBarState();
}

class _ChatVoiceRecordBarState extends State<ChatVoiceRecordBar> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onLongPressStart: (details) {
        widget.onLongPressStart(details);
      },
      onLongPressEnd: (details) {
        widget.onLongPressEnd(details);
      },
      onLongPressMoveUpdate: (details) {
        widget.onLongPressMoveUpdate(details);
        // Offset global = details.globalPosition;
        // Offset local = details.localPosition;
        // print('global:$global');
        // print('local:$local');
      },
      child: ButtonWidget.text(
        'Hold and speak',
        textColor: '#04A5FC'.toColor,
        fontSize: 12,
        alignment: Alignment.center,
        height: 36.w,
        backgroundColor: '#CAECFF'.toColor,
        borderRadius: 36.w,
        hasInkWell: false,
      ),
    );
  }
}
